package com.aube.interact.model;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by huyaonan on 15/11/7.
 */
public class OptionItem implements Serializable {
    public String optionId="";
    public String optionValue="";
    public int count=0;

    //新增
    public String h5url="";
    public String answer="";//if it is the answer, value is 'Y'
    public PicItem picinfo;

    public boolean isRightAnswer() {
        return "Y".equalsIgnoreCase(answer);
    }

    public static OptionItem parse(JSONObject jsonObject) {
        if(jsonObject == null)
            return new OptionItem();
        OptionItem item = new OptionItem();
        item.optionId = jsonObject.optString("optionId");
        item.optionValue = jsonObject.optString("optionValue");
        item.h5url = jsonObject.optString("h5url");
        item.answer = jsonObject.optString("answer");
        item.count = jsonObject.optInt("count");
        item.picinfo = PicItem.parse(jsonObject.optJSONObject("picinfo"));
        return item;
    }

}
